/**
 * Copyright (c) 2018 软唐 All rights reserved.
 *
 * https://www.softtown.cn
 *
 * 版权所有，侵权必究！
 */

package com.softtown.modules.dapai.controller;

import com.github.pagehelper.PageInfo;
import com.softtown.common.utils.Result;
import com.softtown.modules.dapai.dto.CompAfterSaleAPPDTO;
import com.softtown.modules.dapai.dto.CompAfterSaleDTO;
import com.softtown.modules.dapai.dto.CompAfterSaleAddDTO;
import com.softtown.modules.dapai.dto.CompServiceOrderAPPDTO;
import com.softtown.modules.dapai.entity.CompAfterSaleAPPEntity;
import com.softtown.modules.dapai.entity.CompAfterSaleEntity;
import com.softtown.modules.dapai.entity.CompServiceOrderAPPEntity;
import com.softtown.modules.dapai.service.CompAfterSaleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* @Author: Ding Ya Yong
* @Description: 售后申请单
* @date: 2022/1/2 20:47
* @Param:
* @return:
*/
@RestController
@RequestMapping("afterSale")
@Api(tags="售后申请单")
public class CompAfterSaleController {

    @Resource
    private CompAfterSaleService compAfterSaleService;

    @PostMapping("getAfterSalePageList")
    @ApiOperation("获取售后申请单分页")
    public Result getAfterSalePageList(@RequestBody CompAfterSaleDTO compAfterSaleDTO) {
        PageInfo<CompAfterSaleDTO> compAfterSaleDTOPageInfo = compAfterSaleService.getAfterSalePageList(compAfterSaleDTO);
        return new Result<PageInfo<CompAfterSaleDTO>>().ok(compAfterSaleDTOPageInfo);
    }



    @PostMapping("getAfterSaleById")
    @ApiOperation("获取售后申请单详情")
    public Result<CompAfterSaleAddDTO> getAfterSaleById(@RequestBody CompAfterSaleDTO compAfterSaleDTO) {
        CompAfterSaleAddDTO compAfterSaleAddDTO = compAfterSaleService.getAfterSaleById(compAfterSaleDTO.getCompId(),compAfterSaleDTO.getId());
        return new Result<CompAfterSaleAddDTO>().ok(compAfterSaleAddDTO);
    }


    @PostMapping("addAfterSale")
    @ApiOperation("添加售后申请单")
    public Result addAfterSale(@RequestBody CompAfterSaleAddDTO CompAfterSaleAddDTO) {
        Result result = new Result<>();
        compAfterSaleService.addAfterSale(CompAfterSaleAddDTO);
        return result;
    }

    @PostMapping("updateAfterSale")
    @ApiOperation("修改售后申请单")
    public Result updateAfterSale(@RequestBody CompAfterSaleAddDTO CompAfterSaleAddDTO) {
        Result result = new Result<>();
        compAfterSaleService.updateAfterSale(CompAfterSaleAddDTO);
        return result;
    }

    @PostMapping("deleteAfterSale")
    @ApiOperation("删除售后申请单")
    public Result deleteAfterSale(@RequestBody CompAfterSaleDTO compAfterSaleDTO) {
        Result result = new Result<>();
        compAfterSaleService.deleteAfterSale(compAfterSaleDTO);
        return result;
    }

    @PostMapping("getAfterSalePageListAPP")
    @ApiOperation("获取售后申请单分页APP")
    public Result getAfterSalePageListAPP(@RequestBody CompAfterSaleAPPDTO compAfterSaleAPPDTO) {
        PageInfo<CompAfterSaleAPPDTO> compAfterSaleAPPDTOPageInfo = compAfterSaleService.getAfterSalePageListAPP(compAfterSaleAPPDTO);
        return new Result<PageInfo<CompAfterSaleAPPDTO>>().ok(compAfterSaleAPPDTOPageInfo);
    }

    @PostMapping("getAfterSaleByIdAPP")
    @ApiOperation("获取售后申请单详情APP")
    public Result<CompAfterSaleAPPDTO> getAfterSaleById(@RequestBody CompAfterSaleAPPDTO compAfterSaleAPPDTO) {
        CompAfterSaleAPPDTO compAfterSaleAPPDTO1 = compAfterSaleService.getAfterSaleByIdAPP(compAfterSaleAPPDTO.getCompId(),compAfterSaleAPPDTO.getId());
        return new Result<CompAfterSaleAPPDTO>().ok(compAfterSaleAPPDTO1);
    }


    @PostMapping("addAfterSaleAPP")
    @ApiOperation("添加售后申请单APP")
    public Result addAfterSaleAPP(@RequestBody CompAfterSaleAPPEntity compAfterSaleAPPEntity) {
        Result result = new Result<>();
        compAfterSaleService.addAfterSaleAPP(compAfterSaleAPPEntity);
        return result;
    }

    @PostMapping("disAfterSaleAPP")
    @ApiOperation("分配售后申请单APP")
    public Result disAfterSaleAPP(@RequestBody CompServiceOrderAPPEntity compServiceOrderAPPEntity) {
        Result result = new Result<>();
        compAfterSaleService.disAfterSaleAPP(compServiceOrderAPPEntity);
        return result;
    }

}
